/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

typedef struct ListNode ListNode;

void deleteNode(ListNode* Node)
{
    Node->val = Node->next->val;
    Node->next = Node->next->next;
}

ListNode* deleteMiddle(ListNode* head)
{
    int n = 0;
    ListNode* pcur = head;

    while (pcur)
    {
        n++;
        pcur = pcur->next;
    }

    if (n == 1)
        return NULL;

    if (n == 2)
    {
        head->next = NULL;
        return head;
    }

    pcur = head;
    int cnt = n / 2;
    n = 0;
    while (pcur)
    {
        if (cnt == n)
        {
            deleteNode(pcur);
        }
        pcur = pcur->next;
        n++;
    }
    return head;
}